import toolRegex from "./tool-regex";
import { store } from "@/stores";

const toolImg = {
  img(key) {
    let bucket = "app-bucket";
    if (toolRegex.isHttp(key) || !toolRegex.isImg(key)) {
      return key;
    }
    let splits = key.split("/");
    if (splits.length > 1) {
      bucket = splits[0];
      key = splits[1];
    }
    return `${store.app.baseApi}/public/storage/get/402809817fbc4f3d017fbcbed26a001d/${bucket}/${key}`;
    // return `${store.app.baseApi}/public/storage/get-file?channelBusinessId=402809817fbc4f3d017fbcbed26a001d&bucketName=app-bucket&fileKey=${key}`;
  },
};

export default toolImg;
